#include "mprpcapplication.h"
#include "mprpcchannel.h"
#include "user.pb.h"
#include <iostream>
#include <memory>

int main(int argc, char **argv) {
  MprpcApplication::Init(argc, argv);
  std::shared_ptr<MprpcChannel> p = std::make_shared<MprpcChannel>();
  fixbug::UserServiceRpc_Stub stub(p.get());
  fixbug::LoginRequest request;
  request.set_name("zhang san");
  request.set_pwd("123456");

  fixbug::LoginResponse response;
  stub.Login(nullptr, &request, &response, nullptr);

  if (0 == response.result().errcode()) {
    std::cout << "rpc login response:" << response.success() << std::endl;
  } else {
    std::cout << "rpc login error:" << response.result().errmsg() << std::endl;
  }

  fixbug::RegistryRequest request2;
  request2.set_name("li si");
  request2.set_pwd("654321");

  fixbug::RegistryResponse response2;
  stub.Registry(nullptr, &request2, &response2, nullptr);
  if (0 == response2.result().errcode()) {
    std::cout << "rpc registry response:" << response2.success() << std::endl;
  } else {
    std::cout << "rpc registry error:" << response2.result().errmsg()
              << std::endl;
  }
  return 0;
}